home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
jazlib.arc
/
JZGETMEM.C
< prev
next >
Wrap
Text File
|
1988-12-18
|
1KB
|
36 lines
/*
┌────────────────────────────────────────────────────────────────────────────┐
│jzgetmem │
│Return the segment value of a pointer to free memory. │
│The returned value should be orred into a far pointer like so: │
│char far *w; │
│ │
│w = (char far*) ((long) seg_value << 16); │
│ │
│ (C) JazSoft Software by Jack A. Zucker (301) 794-5950 │
└────────────────────────────────────────────────────────────────────────────┘
*/
jzgetmem(fbytes , fseg)
unsigned int fbytes;
int *fseg;
{
TREG wreg;
wreg.h.ah = 0x48; /* dos allocate memory */
if (fbytes % 16) wreg.x.bx = fbytes / 16 + 1;
else wreg.x.bx = fbytes / 16; /* convert to paragraphs */
msdos(&wreg);
if (wreg.x.flags & 1) { /* can't allocate memory */
*fseg = wreg.x.bx; /* return paras free */
return(-1);
}
else {
*fseg = wreg.x.ax; /* return seg:0 to alloc mem */
return(0);
}
}